package com.esd.db.service;

import java.util.List;
import java.util.Map;

import com.esd.db.model.task;
import com.esd.db.model.taskWithBLOBs;

public interface TaskService {
	int getTaskCountByPackIdAndTaskStatus(int packId, int taskStuts, String taskNameCondition);

	List<task> getLikeTaskName(int packId, int page, int taskStuts, String taskNameCondition, int row);

	int deleteByPrimaryKey(Integer taskId);

	int deleteByPackId(Integer packId);

	int insert(taskWithBLOBs record);

	int insertSelective(taskWithBLOBs record);

	taskWithBLOBs selectByPrimaryKey(Integer taskId);

	List<task> selectAllTaskId();

	List<task> getAllDoingTaskByWorkerId(Integer workerId);

	List<task> getAllHistoryTaskByWorkerId(Integer workerId);

	List<task> getAllTaskByPackId(Integer packId);
	//worker下载任务
	List<taskWithBLOBs> getTaskOrderByTaskLvl(int downTaskCount, int packId,int userId,int workerId,int packType,String downPackName,String wrongPath,String realName,String userName);

	List<taskWithBLOBs> updateWorkerIdDowningTask(int downTaskCount, int packId,int userId,int workerId,int packType,String downPackName,String wrongPath,String realName,String userName);
		
	List<taskWithBLOBs> getTaskbyWorkerIdTaskUpload(int workerId,int task_upload);
	//----------------------------------------------------------------------------
	int updateByPrimaryKeySelective(taskWithBLOBs record);
	
	int updateDownTaskByTaskId(taskWithBLOBs record);

	int updateByPrimaryKeyWithBLOBs(taskWithBLOBs record);

	int updateByPrimaryKey(task record);

	int updateByPackId(task task);

	int updateByWorkerId(int inspector,int taskEffective,int updateId,String updateMethod,int workerId,String firstDate,String endDate);
	
	int getUndoTaskCount();

	int getCountTaskDoing(int packType);

	List<taskWithBLOBs> get1TaskByTaskName(String taskName);

	int getTaskCountByPackId(Integer packId);

	int getDoingTaskCountByPackId(Integer packId);

	int getFinishTaskCountByPackId(Integer packId);

	List<taskWithBLOBs> getFinishTaskByPackId(Integer packId);

	String getTaskDirByTaskId(Integer taskId);

	List<taskWithBLOBs> getDoingTaskByWorkerId(Integer workerId);

	List<task> getAllTaskPagesByPackId(Map<String, Integer> map);

	List<task> getDoingTaskPagesByPackId(Map<String, Integer> map);

	List<task> getFinishTaskPagesByPackId(Map<String, Integer> map);

	int getFreePackCount();

	int updateByTaskId(task task);

	int getTaskLvlByPackId(int packId);

	int getUndoTaskCountByPackId(int packId);
	
	int getWorkerIdZeroCountByPackId(Integer packId);
	
	//int updateByLimit(Map<String, Object> map);
	
	/**
	 * 按人审核 更新task
	 * @param workerId  工作者id
	 * @param taskEffective  task状态
	 * @param downPackNames  批次下载包名
	 * @param uploadUUID  任务上传批次
	 * @param sendBackType  退回方式标识
	 * @return
	 */
	int updateAduitByWorkerId(int workerId,int taskEffective, List<String> downPackNames, String uploadUUID, int sendBackType, int[] unqualifiedTaskIds);
	
	int updateFileByTaskId(int taskId,byte[] textGrid,byte[] tag,double taskMarkTime);
	//回收任务
	int updateWorkerIdByWorkerId(int workerId,int taskId);
	
	int updateByWorkerIdAndTaskUpload(int workerId,int taskUpload);
	
	int updateAduitForInspectByDay(List<Integer> taskIds, int taskEffective);

	int updateAduitForInspectByPackage(List<Integer> taskIds, int taskEffective);
	
	/**
	 * 下载审核任务时   根据不同种类添加审核人id到对应字段
	 * @param taskId   任务id
	 * @param userId   审核人id
	 * @param type     审核类型  1，按人审核  2，按天审核， 3，按包审核
	 * @return
	 */
	int updateInspUseridByTaskId(int[] taskIds, int userId, int type);

	int updateAduitByWorkerIdForInspByUser(int workerId, int taskEffective, String uploadUUID);
	
	/**
	 * 按天审核  更新不合格任务    只有不合格时才可调用
	 * @param workerIds  被退回的工作者id 
	 * @param insDate    第一次审核日期  查询条件
	 * @param workGroupCode 所属工作组
	 * @return
	 */
	int updateAduitForInspectByDayIsUnqualified(int[] workerIds, String insDate,String searchTime, String workGroupCode);
	
	/**
	 * 按包审核  更新不合格任务    只有不合格时才可调用
	 * @param workerIds  被退回的工作者id 
	 * @param packId    包id
	 * @return
	 */
	int updateAduitForInspectByPackageIsUnqualified(int[] workerIds, int packId, int sendBackType, int[] unqualifiedTaskIds);
	
	/**
	 * 快速审核  更新不合格任务    只有不合格时才可调用
	 * @param workerIds  被退回的工作者id 
	 * @param packId    包id
	 * @return
	 */
	int updateAduitForQuickInspectionIsUnqualified(int[] workerIds, int packId);
	
	/**
	 * 审核修改textgrid文件用
	 * @param taskWithBLOBs
	 * @return
	 */
	int modifyTaskTextgrid(taskWithBLOBs taskWithBLOBs);

	/**
	 * 通过多个taskid查找带有文件的task
	 * @param taskIds
	 * @return
	 */
	List<taskWithBLOBs> getTaskWithBLOBsByTaskIds(int[] taskIds);
	
	/**
	 * 检查任务是否又被修改过
	 * @param taskId
	 * @return
	 */
	boolean isTaskModified(Integer taskId);
	
	/**
	 * 获取下载任务的中被修改过的任务的Id
	 * @param taskId 
	 * @return
	 */
	List<Integer> getModifiedTaskIds(String[] taskIds);
	
	/**
	 * 查找任务最后一次修改人的用户名
	 * @param taskId
	 * @return
	 */
	String getLastModifiedUsernameByTaskid(int taskId);
	
	/**
	 * 查询审核下载需要的任务
	 * @param taskId
	 * @return
	 */
	taskWithBLOBs selectTaskForInspDownloadByTaskId(Integer taskId);
	
	List<taskWithBLOBs> getFinishTaskByDateCondition(String Begin, String end);

	List<taskWithBLOBs> getFinishTaskByPackageName(String releasePackageName);
}